<?php
//用户收藏
class App_Like extends Data_Base
{
    public function __construct ($type, $nid)
    {
        $this->_type = $type;
        $this->_nid = $nid;
    }

	//用户收藏信息
    public function uidListByLiked ()
    {
        $query = DB::select(DB::expr('distinct(`uid`) as uid'))
            ->from('user_v2_actions')
            ->where('type', '=', $this->_type)
            ->where('nid', '=', $this->_nid)
            ->execute();

        $uids = array();
        foreach ($query as $rs)
            $uids[] = $rs['uid'];

        return $uids;
    }

    public function nidListByUid ($uid)
    {
        $query = DB::select('nid')
            ->from('user_v2_actions')
            ->where('type', '=', $this->_type)
            ->where('uid', '=', $uid)
            ->order_by('created', 'desc')
            ->execute();

        $ret = array();
        foreach ($query as $rs)
        {
            $ret[] = $rs['nid'];
        }

        return $ret;
    }
}
